package controllers;

import java.util.GregorianCalendar;
import java.util.Vector;

import javax.swing.table.AbstractTableModel;
import models.*;
public class MyTableDiasSemana extends AbstractTableModel {

	private String [] columnNames = {"Dia","Horario de inicio","Horario de partida", "Frecuencia de turnos"};
    private Vector<Dia_Semana> dias;


    public MyTableDiasSemana(Vector<Dia_Semana> dias) 
    {
            this.dias =dias;
    }  
    public int getColumnCount() {
            return columnNames.length;
    }
    public int getRowCount() {
            return this.dias.size();
    }
    public Dia_Semana getDiaAt(int row){
        	   return dias.get(row);
    }

    public void removeDiaAt(int row){
            dias.remove(row);
            fireTableDataChanged();
    }

    public void addDia(Dia_Semana dia) {
            dias.add(dia);
            fireTableDataChanged();
    }

    public void addDiasList(Vector<Dia_Semana> dias) {
            this.dias.addAll(dias);
            fireTableDataChanged();
    }


    public Object getValueAt(int row, int col) {
    		Dia_Semana dia = dias.get(row);
            switch (col) {
            case 0:
            		return dia.getNombre();
            case 1:
            	  if(dia.getHorarioInicial()==null)
            		  return "Dia no laboral";
            	  else
            		  return dia.getHorarioInicial();
            case 2:
                    if(dia.getHorarioFinal()==null)
                    	return "Dia no laboral";
                    else 
                    {
                    	return dia.getHorarioFinal();
                    }
            case 3:
            		if(dia.getFrecuencia()==0)
            			return "-";
            		else
            			return dia.getFrecuencia();
            default:
                    return null;
            }
    }


    public Vector<Dia_Semana> getDias() {
            return dias;
    }

    @Override
    public String getColumnName(int col){
            return columnNames[col];
    }
    

}
